import 'package:get/get.dart';
import 'package:note/pages/home_page/logic.dart';
import 'package:note/pages/unlock_page/logic.dart';

import 'state.dart';

const String RootPageNameHome = 'home';
const String RootPageNameUnlock = 'unlockApp';

class RootLogic extends GetxController {
  final RootState state = RootState();

  void setPage(String name) {
    if (state.name.value == name) return;
    String oldName = state.name.value;
    state.name.value = name;
    if (oldName == RootPageNameUnlock) {
      Get.delete<UnlockLogic>();
    } else if (oldName == RootPageNameHome) {
      Get.delete<HomePageLogic>();
    }
  }
}
